<?php
namespace app\index\controller;

use app\common\key\AdKey;

/**
 * @description : [故事控制器]
 * Class Story
 * @package app\index\controller
 */
class Story extends Base
{
    public function index()
    {
        $ad = $this->getAdByType(AdKey::TYPE_STORY);
        $story = model('StoryItem')->order(['type'=>'DESC','sort'=>'ASC'])->select();
        foreach ($story AS $key=>$val){
            $story[$key]['content'] = htmlspecialchars($val['content']);
        }
        $storyLine = ceil(count($story)/2);
        return $this->fetch('', [
            'ad' => $ad[0],
            'story' => $story,
            'story_line' => $storyLine,
        ]);

    }
}
